Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
replace-ext
Advanced tools
The replace-ext npm package is a utility for replacing the extension of a file path string. It is particularly useful in build processes and file manipulation tasks where you need to change file extensions programmatically.
Replace File Extension
This feature allows you to replace the extension of a given file path. In the code sample, the extension of 'file.txt' is changed to '.md', resulting in 'file.md'.
const replaceExt = require('replace-ext');
const filePath = 'example/file.txt';
const newFilePath = replaceExt(filePath, '.md');
console.log(newFilePath); // Outputs: 'example/file.md'
The 'path' module is a built-in Node.js module that provides utilities for working with file and directory paths. It includes the 'path.format' and 'path.parse' methods, which can be used to achieve similar functionality to replace-ext by manually changing the file extension.
The 'upath' package is a utility for working with file paths across different operating systems. It provides methods like 'upath.changeExt' which can be used to change the file extension, similar to replace-ext. However, upath offers additional cross-platform path handling features.
Replaces a file extension with another one.
var replaceExt = require('replace-ext');
var path = '/some/dir/file.js';
var newPath = replaceExt(path, '.coffee');
console.log(newPath); // /some/dir/file.coffee
replaceExt(path, extension)
Replaces the extension from path
with extension
and returns the updated path string.
Does not replace the extension if path
is not a string or is empty.
Available as part of the Tidelift Subscription
The maintainers of replace-ext and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.
MIT
FAQs
Replaces a file extension with another one.
The npm package replace-ext receives a total of 5,588,836 weekly downloads. As such, replace-ext popularity was classified as popular.
We found that replace-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.